
using System;
using System.Collections;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
 // ERROR: Not supported in C#: OptionDeclaration
namespace NCS_CS
{
	internal class CMultiPower
	{

		double[] bp;
		double[] ep;
		double[] tm;
		int n;
        //int methodid;
		double starttime;
		public double totalTime;
		int state;
		public void loadPara()
		{
			int at = 0;
			n = ModMain.method1.powerList.Count;
			if (n > 0) {
				bp=new double[n];
                ep=new double[n];
                tm = new double[n];
				 // ERROR: Not supported in C#: ReDimStatement

				at = 0;
                //NCS.powerSet p = null;
				foreach (NCS.powerSet p in ModMain.method1.powerList) {
                    //p = p_loopVariable;
					totalTime = 0;
					bp[at] = p.begin_power;
					ep[at] = p.end_power;
					tm[at] = p.time;
					totalTime = totalTime + tm[at];
					at = at + 1;
				}
			}
		}
		public void beginPower()
		{
			starttime = ModMain.myTimer();
			state = 0;
		}
		public double getPower()
		{
			double power = 0;

			try {
				if ((ModMain.myTimer() - starttime) > tm[state]) {
					starttime = starttime + tm[state];
					state = state + 1;
				}
				power = ModMain.myDiv( ModMain.myTimer() - starttime,  Convert.ToSingle(tm[state])) * (ep[state] - bp[state]) + bp[state];
			} catch (IndexOutOfRangeException e) {
				power = 0;
                modLog.savelogmsg(e.ToString()); 
			}
			return power;
		}
	}
}
